package com.zkk.web;

import com.alibaba.fastjson.JSON;
import com.zkk.pojo.Card;
import com.zkk.service.CardService;
import com.zkk.service.impl.CardServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;

@WebServlet("/query")
public class queryMoney extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id_card = req.getParameter("id_card");
        Card card = new Card();
        card.setId_card(id_card);
        CardService cardService = new CardServiceImpl();
        BigDecimal money = cardService.queryMoney(card);
        String s = JSON.toJSONString(money);
        resp.getWriter().write(s);
    }
}
